home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-06 | 8.8 KB | 407 lines | [TEXT/CWIE] |
- // Radios.cp
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "DDocData.h"
- #include "EverythingEngine.h"
- #include "EverythingDoc.h"
-
- #include "Radios.h"
-
-
- //----------
- void Radios::Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- Radios* winObj = new Radios;
-
- if (winObj != nil) {
- winObj->Open (inDoc);
- winObj->ConnectToData (inData);
- }
- }
-
- //----------
- Radios::Radios ()
- {
- mData = nil;
- }
-
- //----------
- Radios::~Radios ()
- {
- }
-
- //----------
- EverythingEngine* Radios::GetEngine ()
- {
- return (EverythingEngine*) mDoc->mEngine;
- }
-
- //----------
- void Radios::Open (
- AMDoc* inDoc)
- {
- WindowPtr window;
- Handle wftb;
-
- mDoc = inDoc;
-
- window = GetNewCWindow (WIND_Radios, nil, (WindowPtr) -1L);
- if (mDoc->mEngine->GetFilename () [0] != 0) {
- SetWTitle (window, mDoc->mEngine->GetFilename ());
- }
- mWindow = window;
- ((EverythingDoc*)mDoc)->mRadiosPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) this);
- SetPort (window);
- SetInfo (window);
-
- wftb = ::GetResource ('Wftb', WIND_Radios);
-
- CreateRootControl (window, &mRootControl);
-
- vScroll = nil;
- hScroll = nil;
-
-
- mRadioGroupGroupHandle = GetNewControl (CNTL_RadioGroupGroup, window);
-
- mStandard3Handle = ::GetNewControl (CNTL_Standard3, window);
- EmbedControl (mStandard3Handle, mRadioGroupGroupHandle);
- SetWindowItemFont (mStandard3Handle, wftb, 2);
-
- mGroupBoxHandle = GetNewControl (CNTL_GroupBox, window);
- SetWindowItemFont (mGroupBoxHandle, wftb, 3);
- mGroupGroupHandle = GetNewControl (CNTL_GroupGroup, window);
- EmbedControl (mGroupGroupHandle, mGroupBoxHandle);
- mGroupRadio1Handle = GetNewControl (CNTL_GroupRadio1, window);
- SetWindowItemFont (mGroupRadio1Handle, wftb, 5);
- EmbedControl (mGroupRadio1Handle, mGroupGroupHandle);
- mGroupRadio2Handle = GetNewControl (CNTL_GroupRadio2, window);
- SetWindowItemFont (mGroupRadio2Handle, wftb, 6);
- EmbedControl (mGroupRadio2Handle, mGroupGroupHandle);
- mGroupRadio3Handle = GetNewControl (CNTL_GroupRadio3, window);
- SetWindowItemFont (mGroupRadio3Handle, wftb, 7);
- EmbedControl (mGroupRadio3Handle, mGroupGroupHandle);
-
- mGraphic3BoxHandle = GetNewControl (CNTL_Graphic3Box, window);
- SetWindowItemFont (mGraphic3BoxHandle, wftb, 8);
- mGraphic3GroupHandle = GetNewControl (CNTL_Graphic3Group, window);
- EmbedControl (mGraphic3GroupHandle, mGraphic3BoxHandle);
-
- mStopHandle = ::GetNewControl (CNTL_Stop, window);
- EmbedControl (mStopHandle, mGraphic3GroupHandle);
- SetWindowItemFont (mStopHandle, wftb, 10);
-
- mGoHandle = ::GetNewControl (CNTL_Go, window);
- EmbedControl (mGoHandle, mGraphic3GroupHandle);
- SetWindowItemFont (mGoHandle, wftb, 11);
-
- mBevel3BoxHandle = GetNewControl (CNTL_Bevel3Box, window);
- SetWindowItemFont (mBevel3BoxHandle, wftb, 12);
- mBevel3GroupHandle = GetNewControl (CNTL_Bevel3Group, window);
- EmbedControl (mBevel3GroupHandle, mBevel3BoxHandle);
-
- mRadioButtonHandle = ::GetNewControl (CNTL_RadioButton, window);
- EmbedControl (mRadioButtonHandle, mBevel3GroupHandle);
- SetWindowItemFont (mRadioButtonHandle, wftb, 14);
- SetBevelButtonGraphicAlignment (mRadioButtonHandle, kControlBevelButtonAlignCenter, 0, 0);
-
- mRadioButton2Handle = ::GetNewControl (CNTL_RadioButton2, window);
- EmbedControl (mRadioButton2Handle, mBevel3GroupHandle);
- SetWindowItemFont (mRadioButton2Handle, wftb, 15);
- SetBevelButtonGraphicAlignment (mRadioButton2Handle, kControlBevelButtonAlignCenter, 0, 0);
-
- mTextBoxHandle = GetNewControl (CNTL_TextBox, window);
- SetWindowItemFont (mTextBoxHandle, wftb, 16);
- mTextGroupHandle = GetNewControl (CNTL_TextGroup, window);
- EmbedControl (mTextGroupHandle, mTextBoxHandle);
-
- mNameHandle = ::GetNewControl (CNTL_Name, window);
- EmbedControl (mNameHandle, mTextGroupHandle);
- SetWindowItemFont (mNameHandle, wftb, 18);
-
- mKindHandle = ::GetNewControl (CNTL_Kind, window);
- EmbedControl (mKindHandle, mTextGroupHandle);
- SetWindowItemFont (mKindHandle, wftb, 19);
-
- mSizeHandle = ::GetNewControl (CNTL_Size, window);
- EmbedControl (mSizeHandle, mTextGroupHandle);
- SetWindowItemFont (mSizeHandle, wftb, 20);
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- //----------
- void Radios::Close ()
- {
- mData->RemoveResponder (this);
-
- ((EverythingDoc*)mDoc)->mRadiosPtr = nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- delete this;
- }
-
- //----------
- void Radios::ConnectToData (
- DDocData* inData)
- {
- mData = inData;
- mData->AddResponder (this);
-
- SetControlValue (mRadioGroupGroupHandle, mData->GetRadioGroup ());
- SetControlValue (mGroupGroupHandle, mData->GetGroup ());
- SetControlValue (mGraphic3GroupHandle, mData->GetGraphic ());
- SetControlValue (mBevel3GroupHandle, mData->GetBevel ());
- SetControlValue (mTextGroupHandle, mData->GetText ());
- }
-
- //----------
- void Radios::DataChanged (
- long inDataID)
- {
- if (inDataID == idRadioGroup) {
- SetControlValue (mRadioGroupGroupHandle, mData->GetRadioGroup ());
- }
- if (inDataID == idGroup) {
- SetControlValue (mGroupGroupHandle, mData->GetGroup ());
- }
- if (inDataID == idGraphic) {
- SetControlValue (mGraphic3GroupHandle, mData->GetGraphic ());
- }
- if (inDataID == idBevel) {
- SetControlValue (mBevel3GroupHandle, mData->GetBevel ());
- }
- if (inDataID == idText) {
- SetControlValue (mTextGroupHandle, mData->GetText ());
- }
- }
-
- //----------
- void Radios::Control (
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- ExitCurField ();
-
- if (whichControl == mRadioGroupGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- mData->SetRadioGroup (GetControlValue (mRadioGroupGroupHandle));
- }
- }
- if (whichControl == mGroupGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- mData->SetGroup (GetControlValue (mGroupGroupHandle));
- }
- }
- if (whichControl == mGraphic3GroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- mData->SetGraphic (GetControlValue (mGraphic3GroupHandle));
- }
- }
- if (whichControl == mBevel3GroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- mData->SetBevel (GetControlValue (mBevel3GroupHandle));
- }
- }
- if (whichControl == mTextGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- mData->SetText (GetControlValue (mTextGroupHandle));
- }
- }
- }
-
- //----------
- void Radios::MouseIn (
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void Radios::ExitCurField ()
- {
- ControlHandle focus;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- }
- }
-
- //----------
- void Radios::TypeIn (
- char ch)
- {
- ControlHandle focus;
- SInt16 keyCode;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- ExitCurField ();
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- DoTab ((curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = (SInt16)(curEvent.message & keyCodeMask);
- HandleControlKey (focus, keyCode, ch, (SInt16)curEvent.modifiers);
- mDoc->mEngine->SetDirty ();
- } else {
- SysBeep (1);
- }
- }
-
- //----------
- void Radios::Resize ()
- {
- /* application-specific code to resize items in window */
- }
-
- //----------
- void Radios::Scroll (
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void Radios::DoUndo ()
- {
- } // DoUndo
-
- //----------
- void Radios::DoCut ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECut (curTE);
- mDoc->mEngine->SetDirty ();
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void Radios::DoCopy ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void Radios::DoPaste ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEPaste (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoPaste
-
- //----------
- void Radios::DoClear ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEDelete (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoClear
-
- //----------
- void Radios::DoSelectAll ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void Radios::DoShowClipboard ()
- {
- } // DoShowClipboard
-
- //----------
- Boolean Radios::DoCommand (
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo ();
- break;
- case cmdCut:
- DoCut ();
- break;
- case cmdCopy:
- DoCopy ();
- break;
- case cmdPaste:
- DoPaste ();
- break;
- case cmdClear:
- DoClear ();
- break;
- case cmdSelectAll:
- DoSelectAll ();
- break;
- case cmdShowClipboard:
- DoShowClipboard ();
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-